package com.erlinyou.im.dao.repository.goodfirend;

import java.util.List;
import java.util.Map;

import org.springframework.data.jpa.repository.Query;

import com.erlinyou.base.dao.BaseRepository;
import com.erlinyou.im.model.goodfirend.Goodfirend;
import com.erlinyou.im.model.goodfirend.GoodfirendKey;

public interface GoodfirendRepository extends BaseRepository<Goodfirend, GoodfirendKey>{

	Goodfirend findByUseridAndJid(Long userid, Long jid);

	int deleteByUseridAndJid(Long userId, long rid);

	Goodfirend findByUseridAndJidAndRelation(Long userid, long jid, int relation);

	List<Goodfirend> findByUserid(Long userid);

	@Query(value="SELECT jid from tchat_goodfirend where userid = ?1 AND relation=3 AND FIND_IN_SET(jid,?2)>0",nativeQuery=true)
	List<Map<String, Object>> findByUseridAndRelation1(Long userid, String ids);

	@Query(value="SELECT jid from tchat_goodfirend where userid = ?1 AND relation=3",nativeQuery=true)
	List<Map<String, Object>> findByUseridAndRelation(Long userid);
	
	@Query(value="SELECT jid FROM tchat_goodfirend WHERE userid = ?1 AND relation = 3",nativeQuery=true)
	List<Map<String,Object>> queryUserid(Long userId);

//	@Query(value="SELECT jid,sub,ask,recv,permission,isCanChat,isCanSeePos,isCanSeeExperience,isSeeOtherExperience,isSeeMapPhoto,isAllowContactsGetPosition from ofroster WHERE username = ?1",nativeQuery=true)
//	Map<String, String> selectRoster(Long userId);


	
}
